<div class="block">
	<div class="hd">
		<h2>Enter User Details</h2>
	</div>
	<div class="bd">

		<?php if ($action == 'add'): ?>
		<p>Use the form below to create a new user.</p>

		<?php else:?>
		<p style="float: right; width: 80px; text-align: center; font-size: 9px"><img src="<?='http://www.gravatar.com/avatar.php?size=45&default='.urlencode('/assets/default/images/defaultperson.png')."&gravatar_id=".md5(trim($user->emailaddress));?>" width="45" height="45" /><br />Profile pictures are powered by <a href="http://www.gravatar.com">Gravatar</a>.</p>
		<?php endif;?>


		<p class="clearfix"><strong>Note:</strong> Fields that are listed in <strong>bold</strong> type are required!</p>

		<?=form_open('users/'.$action);?>

		<input type="hidden" name="id" id="id" value="<?= $user->id; ?>" />
		<fieldset>
			<legend>Login Information</legend>
			<dl>
				<dt><label for="emailaddress" class="required">Emailaddress</label></dt>
				<dd><input type="text" name="emailaddress" id="emailaddress" value="<?= $user->emailaddress; ?>" class="{required:true,email:true}" /></dd>
				<dt><label for="password" <?php if ($action == 'add'): ?>class="required"<?php endif;?>>Password</label></dt>
				<dd><input type="password" name="password" id="password" class="{<?php if ($action == 'add'): ?>required:true,<?php endif;?>minLength:5}" /></dd>
				<dt><label for="confirm-password" <?php if ($action == 'add'): ?>class="required"<?php endif;?>>Confirm Password</label></dt>
				<dd><input type="password" name="confirm-password" id="confirm-password" class="{<?php if ($action == 'add'): ?>required:true,<?php endif;?>equalTo:'#password',minLength:5}" /></dd>
			</dl>
		</fieldset>
		<fieldset>
			<legend>Personal Information</legend>
			<dl>
				<dt><label for="firstname" class="required">Firstname</label></dt>
				<dd><input type="text" name="firstname" id="firstname" value="<?= $user->firstname; ?>" class="{required:true}" /></dd>
				<dt><label for="lastname" class="required">Surname</label></dt>
				<dd><input type="text" name="lastname" id="lastname" value="<?= $user->lastname; ?>" class="{required:true}" /></dd>
			</dl>
		</fieldset>
		<fieldset>
			<legend>User Control</legend>
			<dl>
				<dt><label for="active" class="required">Active</label></dt>
				<dd><select name="active" id="active">
						<option value="1" <?php if ($user->active):?>selected="selected"<?php endif;?>>Yes</option>
						<option value="0" <?php if (!$user->active):?>selected="selected"<?php endif;?>>No</option>
					</select></dd>

				<?php if ($departments):?>
					<dt><label for="costcenterid">Department</label></dt>
					<dd>
						<select name="costcenterid">
							<?php foreach($departments as $department):?>
								<option value="<?=$department->id;?>" <?php if ($user->costcenterid == $department->id):?>selected="selected"<?php endif;?>><?=$department->centertitle;?></option>
							<?php endforeach;?>
						</select>
					</dd>

					<dt>
						<label for="autoassign" class="required">Auto Assign</label>
						<p>Would you like this person to automatically be assigned to any project that is assigned to their department?</p>
					</dt>
					<dd>
						<select name="autoassign" id="autoassign">
							<option value="1" <?php if ($user->autoassign):?>selected="selected"<?php endif;?>>Yes</option>
							<option value="0" <?php if (!$user->autoassign):?>selected="selected"<?php endif;?>>No</option>
						</select>
					</dd>
				<?php else:?>
					<input type="hidden" name="costcenterid" value="<?=$user->costcenterid;?>" />
					<input type="hidden" name="autoassign" value="<?=$user->autoassign;?>" />
				<?php endif;?>


				<dt><label for="profiletype" class="required">User Type</label>
					Admin users can access everything.  Standard users can only access jobs or clients they are assigned to.</dt>
				<dd><select name="profiletype" id="profiletype">
						<option value="admin" <?php if ($user->profiletype == 'admin'):?>selected="selected"<?php endif;?>>Admin</option>
						<option value="standard" <?php if ($user->profiletype == 'standard'):?>selected="selected"<?php endif;?>>Standard</option>
					</select></dd>
			</dl>
		</fieldset>

		<input type="submit" name="Submit" value="Save" class="button savebutton">

		<?=form_close();?>

	</div>
</div>

</div>
</div>
</div>

<div id="sidebar" class="yui-b">
		<div class="block">
			<div class="hd">
				<h2></h2>
			</div>
			<div class="bd">
	
			</div>
		</div>
</div>
